﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QuizAppMvc2.Models.QuestaoComAlternativasModels>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    CreateComplex
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <h2>
        CreateComplex</h2>
    <% using (Html.BeginForm()) {%>
    <%: Html.ValidationSummary(true) %>
    <fieldset>
        <legend>Fields</legend>
        <%: Html.DropDownListFor(model => model.materiaid, new SelectList(Model.materias, "idmateria", "nome"), "Selecione a materia")%>
        <%: Html.DropDownListFor(model => model.topicoid, Enumerable.Empty<SelectListItem>(), "Selecione o tópico ") %>
        <%: Html.DropDownListFor(model => model.subtopico, Enumerable.Empty<SelectListItem>(), "Selecione o subtópico ")%><br />
        <br />
        <br />
        <%: Html.EditorFor(m => m.texto) %>
        <br />
        <br />
        <br />


        <% for (int i =0; i < Model.alternativas.Count; i++ )
           { %>
           <%=  Html.RadioButtonFor(m => m.gabarito, i+1 )%>


           <%=  Html.EditorFor(m => m.alternativas[i].texto)%>  <br />
        <% } %>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%: Html.ActionLink("Back to List", "Index") %>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#materiaid").change(function () {
                var url = '<%= Url.Content("~/") %>' + "Questao/abc";
                var ddlsource = "#materiaid";
                var ddltarget = "#topicoid";
                $("#subtopico").empty();
                $.getJSON(url, { year: $(ddlsource).val() }, function (data) {
                    $(ddltarget).empty();
                    $(ddltarget).append('<option value="">Selecione o topico</option>');
                    $.each(data, function (index, optionData) {
                        $(ddltarget).append("<option value='" + optionData.value + "'>" + optionData.novo + "</option>");
                    });
                });
            });
        });

        $(document).ready(function () {
            $("#topicoid").change(function () {
                var url = '<%= Url.Content("~/") %>' + "Questao/Subtopicos";
                var ddlsource = "#topicoid";
                var ddltarget = "#subtopico";
                $.getJSON(url, { year: $(ddlsource).val() }, function (data) {
                    $(ddltarget).empty();
                    $(ddltarget).append('<option value="">Selecione o subtopico</option>');
                    $.each(data, function (index, optionData) {
                        $(ddltarget).append("<option value='" + optionData.value + "'>" + optionData.novo + "</option>");
                    });

                });
            });
        });
    
    </script>
</asp:Content>
